import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/home',
  },
  {
    path: '/home',
    name: 'home',
    component: (resolve) => require(['@/pages/home.vue'], resolve)
  },
  {
    path: '/category',
    name: 'category',
    component: (resolve) => require(['@/pages/category.vue'], resolve)
  },
  {
    path: '/search',
    name: 'search',
    component: (resolve) => require(['@/pages/search.vue'], resolve)
  },
  {
    path: '/login',
    name: 'login',
    component: (resolve) => require(['@/pages/login.vue'], resolve)
  },
  {
    path: '/cart',
    name: 'cart',
    component: (resolve) => require(['@/pages/cart.vue'], resolve)
  },
  {
    path: '/goods',
    name: 'goods',
    component: (resolve) => require(['@/pages/goods.vue'], resolve)
  }
]

const router = new VueRouter({
  routes
})

router.beforeEach((to, from, next)=>{
  next()
})

export default router
